package a.f.h.d;

import a.c.d;
import a.c.e;
import a.c.m;
import a.c.n;
import a.c.x;
import a.c.z;
import a.d.s;
import a.f.h.b.k;
import a.f.o;

public class h
{
  public static final String a = "MIN_DIST_DP_KEY";
  private o b;
  private int c;
  private x d;
  private n e;
  private n f;
  private n g;
  private n h;
  public static int i;
  
  public h(o paramo, int paramInt)
  {
    this.b = paramo;
    this.c = paramInt;
    this.e = paramo.C();
    this.f = paramo.C();
    this.g = paramo.C();
    this.h = paramo.C();
    this.d = paramo.B();
    paramo.a("MIN_DIST_DP_KEY", this.d);
  }
  
  public a_ a(e parame, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
  {
    if (this.d == null) {
      return null;
    }
    a_ locala_ = new a_(parame, paramDouble1, paramDouble2, paramDouble3, paramDouble4);
    this.d.a(parame, locala_);
    this.b.a(parame, locala_.e());
    return locala_;
  }
  
  private void a()
  {
    this.b.a(this.e);
    this.b.a(this.f);
    this.b.a(this.g);
    this.b.a(this.h);
    this.b.j("MIN_DIST_DP_KEY");
    this.b.a(this.d);
  }
  
  private k a(d paramd, boolean paramBoolean)
  {
    z localz = this.b.o(paramd);
    if (!paramBoolean) {
      localz.j();
    }
    a.d.w localw1 = (a.d.w)localz.b();
    a.d.w localw2 = (a.d.w)localz.b();
    if (j.r == 0) {
      if (localw1.a() == localw2.a())
      {
        if (localw1.b() < localw2.b()) {
          return k.c;
        }
        return k.a;
      }
    }
    if (localw1.a() < localw2.a()) {
      return k.b;
    }
    return k.d;
  }
  
  public void c()
  {
    int j = j.r;
    boolean bool = j.q;
    if (j == 0) {
      if (this.d == null) {
        return;
      }
    }
    Object localObject1 = this.b.w();
    Object localObject2;
    do
    {
      if (!((m)localObject1).e()) {
        break;
      }
      localObject2 = ((m)localObject1).a();
      this.e.a(localObject2, a((d)localObject2, true));
      this.f.a(localObject2, a((d)localObject2, false));
      this.g.a(localObject2, this.b.r((d)localObject2));
      if (j == 0)
      {
        if (bool) {
          break label137;
        }
        this.h.a(localObject2, this.b.s((d)localObject2));
        ((m)localObject1).f();
      }
    } while (!bool);
    label137:
    localObject1 = this.b.v();
    do
    {
      if (!((a.c.w)localObject1).e()) {
        break;
      }
      localObject2 = ((a.c.w)localObject1).d();
      a_ locala_ = (a_)this.d.get(localObject2);
      if (bool) {
        return;
      }
      if ((j != 0) || (locala_ != null)) {
        locala_.f();
      }
      ((a.c.w)localObject1).f();
    } while (!bool);
    if (j == 0) {
      a();
    }
  }
  
  class a_
  {
    private static final byte a = 0;
    private static final byte b = 1;
    private static final byte c = 2;
    private static final byte e = 3;
    private e f;
    private int[] g;
    private s h;
    
    public a_(e parame, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
    {
      this.f = parame;
      this.g = new int[4];
      int i = Math.max(0, (int)Math.ceil(paramDouble1));
      int j = Math.max(0, (int)Math.ceil(paramDouble2));
      int k = Math.max(0, (int)Math.ceil(paramDouble3));
      int m = Math.max(0, (int)Math.ceil(paramDouble4));
      if (i4 == 0) {}
      int n = i % h.this.c == 0 ? 0 : h.this.c - i % h.this.c;
      if (i4 == 0) {}
      int i1 = j % h.this.c == 0 ? 0 : h.this.c - j % h.this.c;
      if (i4 == 0) {
        if ((i + n + j + i1) / h.this.c % 2 == 1)
        {
          if (i4 == 0) {
            if (n > i1)
            {
              i1 += h.this.c;
              if (i4 != 0) {
                break label218;
              }
              if (!bool) {
                break label211;
              }
            }
          }
          n += h.this.c;
        }
      }
      label211:
      label218:
      if (i4 == 0) {}
      int i2 = k % h.this.c == 0 ? 0 : h.this.c - k % h.this.c;
      if (i4 == 0) {}
      int i3 = m % h.this.c == 0 ? 0 : h.this.c - m % h.this.c;
      if (i4 == 0)
      {
        if ((k + i2 + m + i3) / h.this.c % 2 == 1)
        {
          if (i4 == 0) {
            if (i2 > i3)
            {
              i3 += h.this.c;
              if (i4 != 0) {
                return;
              }
              if (!bool) {
                break label344;
              }
            }
          }
          i2 += h.this.c;
        }
        label344:
        this.g[0] = (i + n);
        this.g[1] = (j + i1);
        this.g[2] = (k + i2);
        this.g[3] = (m + i3);
        this.h = h.this.b.u(parame);
      }
    }
    
    public int a()
    {
      return this.g[0];
    }
    
    public int b()
    {
      return this.g[1];
    }
    
    public int c()
    {
      return this.g[2];
    }
    
    public int d()
    {
      return this.g[3];
    }
    
    public s e()
    {
      int j = j.r;
      boolean bool = j.q;
      o localo = (o)this.f.g();
      double d1 = localo.s(this.f);
      double d2 = localo.t(this.f);
      int i = 0;
      if (i < this.g.length) {
        if (j == 0) {
          if (i != 0)
          {
            if (j == 0) {
              if (i != 1) {
                break label97;
              }
            }
          }
          else {
            d2 += this.g[i];
          }
        }
      }
      label97:
      while (j != 0)
      {
        if (j == 0)
        {
          if (bool) {
            d1 += this.g[i];
          }
          i++;
        }
        if (!bool) {
          break;
        }
      }
      return new s(d1, d2);
    }
    
    public void f()
    {
      int i = j.r;
      boolean bool = j.q;
      if (i == 0) {
        if (!h()) {
          return;
        }
      }
      a.d.w localw1 = h.this.b.r(this.f);
      a.d.w localw2 = new a.d.w(localw1.a() + c(), localw1.b() + a());
      h.this.b.a(this.f, this.h);
      h.this.b.b(this.f, localw2);
      m localm = this.f.n();
      d locald;
      a.d.w localw3;
      k localk;
      label396:
      do
      {
        do
        {
          if (!localm.e()) {
            break;
          }
          locald = localm.a();
          localw3 = (a.d.w)h.this.g.get(locald);
          localk = (k)h.this.e.get(locald);
          if (bool) {
            break label426;
          }
          if (localk.c(k.a))
          {
            h.this.b.c(locald, new a.d.w(localw3.a(), localw3.b() + a()));
            if (i != 0) {
              continue;
            }
            if (!bool) {}
          }
          else
          {
            if (i == 0) {
              if (localk.c(k.c))
              {
                h.this.b.c(locald, new a.d.w(localw3.a(), localw3.b() - b()));
                if (i != 0) {
                  continue;
                }
                if (!bool) {
                  break label396;
                }
              }
            }
            if (i == 0) {
              if (localk.c(k.d))
              {
                h.this.b.c(locald, new a.d.w(localw3.a() + c(), localw3.b()));
                if (i != 0) {
                  continue;
                }
                if (!bool) {
                  break label396;
                }
              }
            }
            if (i != 0) {
              continue;
            }
            if (localk.c(k.b)) {
              h.this.b.c(locald, new a.d.w(localw3.a() - d(), localw3.b()));
            }
          }
          localm.f();
        } while (!bool);
      } while (i != 0);
      localm = this.f.m();
      label426:
      label709:
      do
      {
        if (!localm.e()) {
          break;
        }
        locald = localm.a();
        localw3 = (a.d.w)h.this.h.get(locald);
        localk = (k)h.this.f.get(locald);
        if (i == 0) {
          if (localk.c(k.a))
          {
            h.this.b.d(locald, new a.d.w(localw3.a(), localw3.b() + a()));
            if (i != 0) {
              continue;
            }
            if (!bool) {
              break label709;
            }
          }
        }
        if (i == 0) {
          if (localk.c(k.c))
          {
            h.this.b.d(locald, new a.d.w(localw3.a(), localw3.b() - b()));
            if (i != 0) {
              continue;
            }
            if (!bool) {
              break label709;
            }
          }
        }
        if (i == 0) {
          if (localk.c(k.d))
          {
            h.this.b.d(locald, new a.d.w(localw3.a() + c(), localw3.b()));
            if (i != 0) {
              continue;
            }
            if (!bool) {
              break label709;
            }
          }
        }
        if (i == 0)
        {
          if (localk.c(k.b)) {
            h.this.b.d(locald, new a.d.w(localw3.a() - d(), localw3.b()));
          }
          localm.f();
        }
      } while (!bool);
    }
    
    public s g()
    {
      return this.h;
    }
    
    public boolean h()
    {
      int j = j.r;
      boolean bool = j.q;
      do
      {
        for (int i = 0; !bool; i++)
        {
          if (i >= this.g.length) {
            break;
          }
          if (bool) {
            break label46;
          }
          if (this.g[i] > 0) {
            return true;
          }
        }
      } while (j != 0);
      label46:
      return false;
    }
  }
}


/* Location:           E:\idea\
 * Qualified Name:     a.f.h.d.h
 * JD-Core Version:    0.7.0.1
 */